package day_01.observer_mode;

/**
 * 布告板
 */
public class CurrentConditionDisplay implements Observer, DisplayElement{
    private float temp;
    private float humidity;

    public CurrentConditionDisplay(Subject weatherData) {
        weatherData.registerObserver(this);
    }

    public void stopDisplay(Subject weatherData){
        weatherData.removeObserver(this);
    }

    @Override
    public void display() {
        System.out.println(temp + "℃ " + humidity + "%");
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        display();
    }
}
